// Tags:
#include <algorithm>
#include <cctype>
#include <cstdio>
#include <cstring>
#include <vector>

const int N = 3e5 + 5, M = 1e6 + 5, inf = 0x3f3f3f3f;
int n, m, q, cnt;
int f[N], fa[N], dep[N], top[N], siz[N], son[N], dfn[N], a[N], b[N], w[N];
int tag[N << 2], min[N << 2], max[N << 2];

struct Edge {
  int v, w;
  Edge() {}
  Edge(int v, int w) : v(v), w(w) {}
  inline bool operator<(const Edge &rhs) const { return w < rhs.w; }
};

struct UEdge : Edge {
  int u;
  UEdge() : Edge() {}
  UEdge(int u, int v, int w) : Edge(v, w), u(u) {}
} g[M];

std::vector<Edge> E[N], G[N];

template <typename T>
inline void read(T &x) {
  x = 0;
  bool flag = false;
  short ch = getchar();
  while (!isdigit(ch)) {
    if (ch == '-') flag = true;
    ch = getchar();
  }
  while (isdigit(ch)) x = (x << 1) + (x << 3) + (ch ^ 48), ch = getchar();
  if (flag) x = -x;
}

int find(int x) { return f[x] == x ? x : f[x] = find(f[x]); }

void dfs1(int u) {
  siz[u] = 1;
  std::sort(E[u].begin(), E[u].end());
  for (auto &i : G[u]) {
    if (i.v != fa[u]) {
      dep[i.v] = dep[u] + 1, fa[i.v] = u, w[i.v] = i.w;
      dfs1(i.v);
      siz[u] += siz[i.v];
      if (siz[son[u]] < siz[i.v]) son[u] = i.v;
    }
  }
}

void dfs2(int u) {
  dfn[u] = ++cnt;
  if (E[u].size() >= 3) a[cnt] = E[u][2].w;
  b[cnt] = w[u];
  if (son[u]) { top[son[u]] = top[u], dfs2(son[u]); }
  for (auto &i : G[u]) {
    if (i.v != son[u] && i.v != fa[u]) {
      top[i.v] = i.v;
      dfs2(i.v);
    }
  }
}

inline void pushup(int x) {
  min[x] = std::min(min[x << 1], min[x << 1 | 1]);
  max[x] = std::max(max[x << 1], max[x << 1 | 1]);
}

void build(int x, int l, int r) {
  if (l == r) { return min[x] = a[l], max[x] = b[l], void(); }
  int mid = (l + r) >> 1;
  build(x << 1, l, mid);
  build(x << 1 | 1, mid + 1, r);
  pushup(x);
}

void modify(int x, int l, int r, int p, int v) {
  if (l == r) return min[x] = v, void();
  int mid = (l + r) >> 1;
  if (p <= mid) modify(x << 1, l, mid, p, v);
  else
    modify(x << 1 | 1, mid + 1, r, p, v);
  pushup(x);
}

int querymin(int x, int l, int r, int L, int R) {
  if (L <= l && r <= R) { return min[x]; }
  int mid = (l + r) >> 1, res = inf;
  if (L <= mid) res = std::min(res, querymin(x << 1, l, mid, L, R));
  if (R > mid) res = std::min(res, querymin(x << 1 | 1, mid + 1, r, L, R));
  return res;
}

int querymax(int x, int l, int r, int L, int R) {
  if (L <= l && r <= R) return max[x];
  int mid = (l + r) >> 1, res = -inf;
  if (L <= mid) res = std::max(res, querymax(x << 1, l, mid, L, R));
  if (R > mid) res = std::max(res, querymax(x << 1 | 1, mid + 1, r, L, R));
  return res;
}

inline int solve(int x, int y) {
  int rmin = inf, rmax = -inf;
  if (E[x].size() >= 2) rmin = std::min(rmin, E[x][1].w);
  if (E[y].size() >= 2) rmin = std::min(rmin, E[y][1].w);
  while (top[x] != top[y]) {
    if (dep[top[x]] < dep[top[y]]) std::swap(x, y);
    rmin = std::min(rmin, querymin(1, 1, n, dfn[top[x]], dfn[x]));
    rmax = std::max(rmax, querymax(1, 1, n, dfn[top[x]], dfn[x]));
    x = fa[top[x]];
  }
  if (dep[x] < dep[y]) std::swap(x, y);
  rmin = std::min(rmin, querymin(1, 1, n, dfn[y], dfn[x]));
  if (x != y) rmax = std::max(rmax, querymax(1, 1, n, dfn[y] + 1, dfn[x]));
  rmin = std::max(rmin, rmax);

  return rmin == inf ? -1 : rmin;
}

int main() {
#ifndef ONLINE_JUDGE
#ifdef LOCAL
  freopen("testdata.in", "r", stdin);
  freopen("testdata.out", "w", stdout);
#else
  freopen("track.in", "r", stdin);
  freopen("track.out", "w", stdout);
#endif
#endif

  read(n), read(m), read(q);
  for (int i = 1, u, v, w; i <= m; ++i) {
    read(u), read(v), read(w);
    E[u].emplace_back(v, w), E[v].emplace_back(u, w);
    g[i] = UEdge(u, v, w);
  }
  std::sort(g + 1, g + m + 1);

  for (int i = 1; i <= n; ++i) f[i] = i;
  for (int i = 1; i <= m; ++i) {
    if (find(g[i].u) != find(g[i].v)) {
      f[find(g[i].u)] = find(g[i].v);
      G[g[i].u].emplace_back(g[i].v, g[i].w),
          G[g[i].v].emplace_back(g[i].u, g[i].w);
    }
  }

  memset(a, inf, sizeof(a));
  memset(b, -inf, sizeof(b));
  fa[1] = 1, top[1] = 1, w[1] = -inf;
  dfs1(1), dfs2(1);
  build(1, 1, n);
  for (int x, y; q; --q) {
    read(x), read(y);
    modify(1, 1, n, dfn[x], inf), modify(1, 1, n, dfn[y], inf);
    printf("%d\n", solve(x, y));
    modify(1, 1, n, dfn[x], a[dfn[x]]), modify(1, 1, n, dfn[y], a[dfn[y]]);
  }
  return 0;
}